<template>
	<view class="sold_list">
		<view class="title">
			<view class="number">售卖数量</view>
			<view class="price">售卖单价</view>
			<view class="total">总价</view>
			<view class="time">时间</view>
		</view>
		<scroll-view scroll-y class="scroll_view" @scrolltolower="loadmore">
			<view class="item" v-for="item in list">
				<view>100担</view>
				<view>￥2.00</view>
				<view>￥200.00</view>
				<view class="time">20230815 23:36:24</view>
			</view>
			<u-loadmore :status="loadmore_status" :color="$store.state.loadmoreColor"
				:lineColor="$store.state.loadmoreColor" line @loadmore="loadmore" />
		</scroll-view>
	</view>
</template>

<script>
	import {
		userSellHistory
	} from '@/request/api.js';
	export default {
		props: {
			type: {
				type: String,
				default: ""
			}
		},
		data() {
			return {
				list: []
			}
		},
		created() {
			this.getList();
		},
		methods: {
			async getList() {
				let {
					list
				} = await userSellHistory({
					page: this.page,
					limit: this.limit,
					field: this.type
				});
				this.last_page = list.last_page;
				list = list.list;
				this.list = this.page == 1 ? list : [...this.list, ...list];
				this.loadmore_status = this.last_page == this.page ? 'nomore' : 'loadmore';
			},
			loadmore() {
				if (this.page < this.last_page) {
					this.page++;
					this.getList();
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.sold_list {
		height: calc(100vh - #{$navbarHeight} - 100rpx - 20rpx);
		padding: 150rpx 40rpx 0;
		box-sizing: border-box;
		background: url(#{$baseImageUrl}/bg/bg3.png) no-repeat;
		background-size: 100% 100%;

		.title {
			height: 68rpx;
			padding-left: 15rpx;
			padding-bottom: 30rpx;
			box-sizing: border-box;
			display: flex;

			view {
				width: 20%;
				color: #FFFFFF;
				font-size: 28rpx;
				font-weight: 400;
				font-family: SimSun;

				&.time {
					flex: 1;
				}
			}
		}

		.scroll_view {
			height: calc(100% - 68rpx);
			padding-bottom: 30rpx;
			box-sizing: border-box;

			.item {
				width: 100%;
				height: 60rpx;
				margin-bottom: 10rpx;
				padding: 0 25rpx;
				box-sizing: border-box;
				background: url(#{$baseImageUrl}/home/i3.png) no-repeat;
				background-size: 100% 100%;
				display: flex;
				justify-content: space-between;
				align-items: center;

				view {
					width: 20%;
					color: #494338;
					font-size: 26rpx;
					font-weight: 400;
					font-family: SimSun;

					&.time {
						flex: 1;
						color: #CD5851;
					}
				}
			}
		}
	}
</style>